package com.huixin.powermonitor.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huixin.powermonitor.common.Result;
import com.huixin.powermonitor.entity.HistoryData;
import com.huixin.powermonitor.service.HistoryDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author huixin
 * @since 2025-07-08
 */
@RestController
@RequestMapping("/history-data")
public class HistoryDataController {
    @Autowired
    private HistoryDataService historyDataService;

    @GetMapping("/show_hd")
    public Result showhd(@RequestParam(defaultValue = "1") int pageNum,
                         @RequestParam(defaultValue = "10") int pageSize) {

        // 创建分页对象
        IPage<HistoryData> page = new Page<>(pageNum, pageSize);

        // 查询所有数据并自动分页
        IPage<HistoryData> dataPage = historyDataService.page(page);

        // 返回结果，包含 list + total
        return Result.suc(dataPage);
    }
}
